/*
 * LutColor.h
 *
 *  Created on: 5 déc. 2009
 *      Author: math
 */

#ifndef LUTCOLOR_H_
#define LUTCOLOR_H_

#include <liblut/core/LutColorSpace.h>
#include <boost/cstdint.hpp>
#include <boost/shared_ptr.hpp>

class LutColor {
    private:
    //les trois composantes de la couleur qu'elle soit définie dans
    //le système RVB ou TSV
    //si RVB: C1=R,C2=V,C3=B
    //si TSL: C1=T,C2=S,C3=L
        int m_C1;
        int m_C2;
        int m_C3;
    //permet de savoir dans quel système a été défini la couleur:
    //RVB systCouleur==0
    //TSL systCouleur=1
        eLutColorSpace m_colorSpace;
        void HSL2RGB(int& C1, int& C2, int& C3);

    public:
        LutColor();
        LutColor(int I1, int I2, int I3, eLutColorSpace I4);
        LutColor(const LutColor& color);
        ~LutColor();

        //get set
        void setValues(int I1, int I2, int I3);
        //void SetColorSpace(int syscolor);
        int getC1() const {return m_C1;}
        int getC2() const {return m_C2;}
        int getC3() const {return m_C3;}
        eLutColorSpace getColorSpace() const {return m_colorSpace;}

        //convert algo
        LutColor toRGB();
};

using namespace boost;

class LutColorI {
  eLutColorSpace m_colorSpace;

  public:
    virtual ~LutColorI() {};
    //get set
    virtual void setValues(uint32_t C1, uint32_t C2, uint32_t C3) = 0;
    virtual uint32_t getC1i() const = 0;
    virtual uint32_t getC2i() const = 0;
    virtual uint32_t getC3i() const = 0;
    virtual void setValues(float C1, float C2, float C3) = 0;
    virtual float getC1f() const = 0;
    virtual float getC2f() const = 0;
    virtual float getC3f() const = 0;

    eLutColorSpace getColorSpace() const { return m_colorSpace;}
};

class LutColorFactory {
  public:
    typedef boost::shared_ptr<LutColor> LutColor_ptr;
    LutColor_ptr CreateColor(uint32_t C1, uint32_t C2, uint32_t C3,
                             eLutColorSpace colorSpace);
    LutColor_ptr CreateColor(eLutColorSpace colorSpace);

};

#endif /* LUTCOLOR_H_ */
